package com.ming_za.odupdaterserver.core.exception;

import lombok.Getter;

/**
 * 用于抛出处理请求出现的异常
 */
@Getter
public class BusinessException extends RuntimeException{

    private final ROEnum eType;
    private final String msg;

    private Object data = null;

    /**
     * @param eType 错误类型
     */
    public BusinessException(ROEnum eType) {
        this.eType = eType;
        this.msg = eType.getDefaultMsg();
    }

    public BusinessException(ROEnum eType, Object data) {
        this.eType = eType;
        this.data = data;
        this.msg = eType.getDefaultMsg();
    }

    /**
     * @param eType 错误类型
     * @param msg 返回到前端的信息
     */
    public BusinessException(ROEnum eType, String msg) {
        this.eType = eType;
        this.msg = msg;
    }

    /**
     * @param message 后台报错信息
     * @param eType 错误类型
     */
    public BusinessException(String message, ROEnum eType) {
        super(message);
        this.eType = eType;
        this.msg = eType.getDefaultMsg();
    }

    /**
     * @param message 后台报错信息
     * @param eType 错误类型
     * @param msg 返回到前端的信息
     */
    public BusinessException(String message, ROEnum eType, String msg) {
        super(message);
        this.eType = eType;
        this.msg = msg;
    }

    /**
     * @param message 后台报错信息
     * @param cause 报错原因
     * @param eType 错误类型
     */
    public BusinessException(String message, Throwable cause, ROEnum eType) {
        super(message, cause);
        this.eType = eType;
        this.msg = eType.getDefaultMsg();
    }
    /**
     * @param message 后台报错信息
     * @param cause 报错原因
     * @param eType 错误类型
     * @param msg 返回到前端的信息
     */
    public BusinessException(String message, Throwable cause, ROEnum eType, String msg) {
        super(message, cause);
        this.eType = eType;
        this.msg = msg;
    }
}
